package top.continew.ai.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.cloud.ai.memory.redis.JedisRedisChatMemoryRepository;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import top.continew.ai.dto.AiProperties;
import top.continew.ai.service.SessionService;

/**
 * 会话消息 服务
 * @Author： Lonni
 * @Date： 2025/8/21  15:27
 */
@Service
@Slf4j
public class SessionServiceImpl implements SessionService {

    @Autowired
    private ChatMemory chatMemory;

    @Resource
    private RedisTemplate redisTemplate;


    /**
     * 获取当前用户的所有会话列表
     * @return
     */
    public String getSessionList() {

        redisTemplate.opsForHash().entries(String.format(AiProperties.SESSION_LIST_KEY, StpUtil.get))

        return chatMemory.getMessages().toString();
    }



}
